/**
 * Created With IntelliJ IDEA
 * Description:牛客网：BM33 二叉树的镜像
 * <a href="https://www.nowcoder.com/practice/a9d0ecbacef9410ca97463e4a5c83be7?tpId=295&tqId=1374963&ru=/exam/oj&qru=/ta/format-top101/question-ranking&sourceUrl=%2Fexam%2Foj">...</a>
 * User: DELL
 * Data: 2022-12-26
 * Time: 22:15
 */


import java.util.*;

class TreeNode {
    int val = 0;
    TreeNode left = null;
    TreeNode right = null;
    public TreeNode(int val) {
      this.val = val;
    }
 }

public class Solution {
    public TreeNode Mirror (TreeNode pRoot) {
        //递归结束条件
        if (pRoot == null) {
            return null;
        }
        //左右结点交换
        TreeNode tmp = pRoot.left;
        pRoot.left = pRoot.right;
        pRoot.right = tmp;
        //分别递归左右结点
        Mirror(pRoot.left);
        Mirror(pRoot.right);
        return pRoot;
    }
}